package com.itheima.advantagesup.controller;

import com.itheima.advantagesup.common.R;
import com.itheima.advantagesup.entity.YddUser;
import com.itheima.advantagesup.service.UserLoginService;
import com.itheima.advantagesup.vo.IndexVO;
import com.itheima.advantagesup.vo.YddUserLoginVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author iTaotao
 * @version 1.0
 * @Description 用户登录
 * @createTime 2023年07月31日 19:00:00
 */
@RestController
@RequestMapping
public class UserLoginController {

    @Autowired
    private UserLoginService userLoginService;

    /**
     * 登录
     *
     * @param yddUser ydd用户
     * @return {@link R}<{@link YddUserLoginVO}>
     */
    @PostMapping("/home/index/login")
    public R<YddUserLoginVO> login(@RequestBody YddUser yddUser) {
        YddUserLoginVO yddUserLoginVO = userLoginService.login(yddUser);
        return R.success(yddUserLoginVO);
    }

    /**
     * 前台用户返回值
     *
     * @return {@link R}<{@link IndexVO}>
     */
    @GetMapping("/index/index")
    public R<IndexVO> indexUser(){
        IndexVO indexVO = userLoginService.indexUser();
        return R.success(indexVO);
    }
}
